package com.lifesting.front;

import javax.faces.component.UIComponentBase;
import javax.faces.context.FacesContext;

//显示一个输入值，一个确定按钮，可激发action event促使invoke application
public class Rns extends UIComponentBase implements ITableAware,ITextAware {

	public static final String COMPONENT_TYPE = "com.lifesting.rns";
	public static final String COMPONENT_FAMILY = "com.lifesting.family";
	// 记录当前输入的表格每页大小，从表格中取，所以不保存。
	private Integer currentNumber;

	public Integer getCurrentNumber() {
		return currentNumber;
	}

	public void setCurrentNumber(Integer currentNumber) {
		this.currentNumber = currentNumber;
	}

	// 如果不设置这个属性，将从父component中找第一个table元素，如果找不到，报错。
	private String tableFor;
	// 名字
	private String text;

	public String getTableFor() {
		return tableFor;
	}

	public void setTableFor(String tableFor) {
		this.tableFor = tableFor;
	}

	@Override
	public String getFamily() {
		return COMPONENT_FAMILY;
	}

	public String getText() {
		return text;
	}

	public void setText(String text) {
		this.text = text;
	}

	private Object[] values;

	@Override
	public Object saveState(FacesContext context) {
		if (values == null) {
			values = new Object[3];
		}
		values[0] = super.saveState(context);
		values[1] = tableFor;
		values[2] = text;

		return values;
	}

	@Override
	public void restoreState(FacesContext context, Object state) {
		values = (Object[]) state;
		super.restoreState(context, values[0]);
		tableFor = (String) values[1];
		text = (String) values[2];
	}

}
